// 1.30
[ 'modifyField', 'image', 'img_media_type', 'patch-add-3d.sql' ],
[ 'addIndex', 'site_stats', 'PRIMARY', 'patch-site_stats-pk.sql' ],
+
+ // 1.31
+ [ 'addTable', 'slots', 'patch-slots.sql' ],
+ [ 'addTable', 'content', 'patch-content.sql' ],
+ [ 'addTable', 'slot_roles', 'patch-slot_roles.sql' ],
+ [ 'addTable', 'content_models', 'patch-content_models.sql' ],
];
}
[ 'renameIndex', 'l10n_cache', 'lc_lang_key', 'PRIMARY', false,
'patch-l10n_cache-primary-key.sql' ],
[ 'doUnsignedSyncronisation' ],
+
+ // 1.31
+ [ 'addTable', 'slots', 'patch-slots.sql' ],
+ [ 'addTable', 'content', 'patch-content.sql' ],
+ [ 'addTable', 'slot_roles', 'patch-slot_roles.sql' ],
+ [ 'addTable', 'content_models', 'patch-content_models.sql' ],
];
}
[ 'doAutoIncrementTriggers' ],
[ 'addIndex', 'site_stats', 'PRIMARY', 'patch-site_stats-pk.sql' ],
+ // 1.31
+ [ 'addTable', 'slots', 'patch-slots.sql' ],
+ [ 'addTable', 'content', 'patch-content.sql' ],
+ [ 'addTable', 'slot_roles', 'patch-slot_roles.sql' ],
+ [ 'addTable', 'content_models', 'patch-content_models.sql' ],
+
// KEEP THIS AT THE BOTTOM!!
[ 'doRebuildDuplicateFunction' ],
[ 'addTable', 'comment', 'patch-comment-table.sql' ],
[ 'addIndex', 'site_stats', 'site_stats_pkey', 'patch-site_stats-pk.sql' ],
[ 'addTable', 'ip_changes', 'patch-ip_changes.sql' ],
+
+ // 1.31
+ [ 'addTable', 'slots', 'patch-slots-table.sql' ],
+ [ 'addTable', 'content', 'patch-content-table.sql' ],
+ [ 'addTable', 'content_moddels', 'patch-content_models-table.sql' ],
+ [ 'addTable', 'slot_roles', 'patch-slot_roles-table.sql' ],
];
}
[ 'migrateComments' ],
[ 'renameIndex', 'l10n_cache', 'lc_lang_key', 'PRIMARY', false,
'patch-l10n_cache-primary-key.sql' ],
+
+ // 1.31
+ [ 'addTable', 'content', 'patch-content.sql' ],
+ [ 'addTable', 'content_models', 'patch-content_models.sql' ],
+ [ 'addTable', 'slots', 'patch-slots.sql' ],
+ [ 'addTable', 'slot_roles', 'patch-slot_roles.sql' ]
];
}
--- /dev/null
+--
+-- The content table represents content objects. It's primary purpose is to provide the necessary
+-- meta-data for loading and interpreting a serialized data blob to create a content object.
+--
+CREATE TABLE /*_*/content (
+
+ -- ID of the content object
+ content_id bigint unsigned PRIMARY KEY AUTO_INCREMENT,
+
+ -- Nominal size of the content object (not necessarily of the serialized blob)
+ content_size int unsigned NOT NULL,
+
+ -- Nominal hash of the content object (not necessarily of the serialized blob)
+ content_sha1 varbinary(32) NOT NULL,
+
+ -- reference to model_id
+ content_model smallint unsigned NOT NULL,
+
+ -- URL-like address of the content blob
+ content_address varbinary(255) NOT NULL
+) /*$wgDBTableOptions*/;
\ No newline at end of file
--- /dev/null
+--
+-- Normalization table for content model names
+--
+CREATE TABLE /*_*/content_models (
+ model_id smallint PRIMARY KEY AUTO_INCREMENT,
+ model_name varbinary(64) NOT NULL
+) /*$wgDBTableOptions*/;
+
+-- Index for looking of the internal ID of for a name
+CREATE UNIQUE INDEX /*i*/model_name ON /*_*/content_models (model_name);
\ No newline at end of file
--- /dev/null
+--
+-- Normalization table for role names
+--
+CREATE TABLE /*_*/slot_roles (
+ role_id smallint PRIMARY KEY AUTO_INCREMENT,
+ role_name varbinary(64) NOT NULL
+) /*$wgDBTableOptions*/;
+
+-- Index for looking of the internal ID of for a name
+CREATE UNIQUE INDEX /*i*/role_name ON /*_*/slot_roles (role_name);
\ No newline at end of file
--- /dev/null
+--
+-- Slots represent an n:m relation between revisions and content objects.
+-- A content object can have a specific "role" in one or more revisions.
+-- Each revision can have multiple content objects, each having a different role.
+--
+CREATE TABLE /*_*/slots (
+
+ -- reference to rev_id
+ slot_revision_id bigint unsigned NOT NULL,
+
+ -- reference to role_id
+ slot_role_id smallint unsigned NOT NULL,
+
+ -- reference to content_id
+ slot_content_id bigint unsigned NOT NULL,
+
+ -- whether the content is inherited (1) or new in this revision (0)
+ slot_inherited tinyint unsigned NOT NULL DEFAULT 0,
+
+ PRIMARY KEY ( slot_revision_id, slot_role_id )
+) /*$wgDBTableOptions*/;
+
+-- Index for finding revisions that modified a specific slot
+CREATE INDEX /*i*/slot_role_inherited ON /*_*/slots (slot_revision_id, slot_role_id, slot_inherited);
\ No newline at end of file
--- /dev/null
+--
+-- The content table represents content objects. It's primary purpose is to provide the necessary
+-- meta-data for loading and interpreting a serialized data blob to create a content object.
+--
+CREATE TABLE /*_*/content (
+
+ -- ID of the content object
+ content_id bigint unsigned NOT NULL CONSTRAINT PK_content PRIMARY KEY IDENTITY,
+
+ -- Nominal size of the content object (not necessarily of the serialized blob)
+ content_size int unsigned NOT NULL,
+
+ -- Nominal hash of the content object (not necessarily of the serialized blob)
+ content_sha1 varchar(32) NOT NULL,
+
+ -- reference to model_id
+ content_model smallint unsigned NOT NULL CONSTRAINT FK_content_content_models FOREIGN KEY REFERENCES /*_*/content_models(model_id),
+
+ -- URL-like address of the content blob
+ content_address nvarchar(255) NOT NULL
+);
\ No newline at end of file
--- /dev/null
+
+--
+-- Normalization table for content model names
+--
+CREATE TABLE /*_*/content_models (
+ model_id smallint NOT NULL CONSTRAINT PK_content_models PRIMARY KEY IDENTITY,
+ model_name nvarchar(64) NOT NULL
+);
+
+-- Index for looking of the internal ID of for a name
+CREATE UNIQUE INDEX /*i*/model_name ON /*_*/content_models (model_name);
\ No newline at end of file
--- /dev/null
+--
+-- Normalization table for role names
+--
+CREATE TABLE /*_*/slot_roles (
+ role_id smallint NOT NULL CONSTRAINT PK_slot_roles PRIMARY KEY IDENTITY,
+ role_name nvarchar(64) NOT NULL
+);
+
+-- Index for looking of the internal ID of for a name
+CREATE UNIQUE INDEX /*i*/role_name ON /*_*/slot_roles (role_name);
\ No newline at end of file
--- /dev/null
+--
+-- Slots represent an n:m relation between revisions and content objects.
+-- A content object can have a specific "role" in one or more revisions.
+-- Each revision can have multiple content objects, each having a different role.
+--
+CREATE TABLE /*_*/slots (
+
+ -- reference to rev_id
+ slot_revision_id bigint unsigned NOT NULL,
+
+ -- reference to role_id
+ slot_role_id smallint unsigned NOT NULL CONSTRAINT FK_slots_slot_role FOREIGN KEY REFERENCES slot_roles(role_id),
+
+ -- reference to content_id
+ slot_content_id bigint unsigned NOT NULL CONSTRAINT FK_slots_content_id FOREIGN KEY REFERENCES content(content_id),
+
+ -- whether the content is inherited (1) or new in this revision (0)
+ slot_inherited tinyint unsigned NOT NULL CONSTRAINT DF_slot_inherited DEFAULT 0,
+
+ CONSTRAINT PK_slots PRIMARY KEY (slot_revision_id, slot_role_id)
+);
+
+-- Index for finding revisions that modified a specific slot
+CREATE INDEX /*i*/slot_role_inherited ON /*_*/slots (slot_revision_id, slot_role_id, slot_inherited);
\ No newline at end of file
CREATE INDEX /*i*/ar_revid ON /*_*/archive (ar_rev_id);
+--
+-- Slots represent an n:m relation between revisions and content objects.
+-- A content object can have a specific "role" in one or more revisions.
+-- Each revision can have multiple content objects, each having a different role.
+--
+CREATE TABLE /*_*/slots (
+
+ -- reference to rev_id
+ slot_revision_id bigint unsigned NOT NULL,
+
+ -- reference to role_id
+ slot_role_id smallint unsigned NOT NULL CONSTRAINT FK_slots_slot_role FOREIGN KEY REFERENCES slot_roles(role_id),
+
+ -- reference to content_id
+ slot_content_id bigint unsigned NOT NULL CONSTRAINT FK_slots_content_id FOREIGN KEY REFERENCES content(content_id),
+
+ -- whether the content is inherited (1) or new in this revision (0)
+ slot_inherited tinyint unsigned NOT NULL CONSTRAINT DF_slot_inherited DEFAULT 0,
+
+ CONSTRAINT PK_slots PRIMARY KEY (slot_revision_id, slot_role_id)
+);
+
+-- Index for finding revisions that modified a specific slot
+CREATE INDEX /*i*/slot_role_inherited ON /*_*/slots (slot_revision_id, slot_role_id, slot_inherited);
+
+--
+-- The content table represents content objects. It's primary purpose is to provide the necessary
+-- meta-data for loading and interpreting a serialized data blob to create a content object.
+--
+CREATE TABLE /*_*/content (
+
+ -- ID of the content object
+ content_id bigint unsigned NOT NULL CONSTRAINT PK_content PRIMARY KEY IDENTITY,
+
+ -- Nominal size of the content object (not necessarily of the serialized blob)
+ content_size int unsigned NOT NULL,
+
+ -- Nominal hash of the content object (not necessarily of the serialized blob)
+ content_sha1 varchar(32) NOT NULL,
+
+ -- reference to model_id
+ content_model smallint unsigned NOT NULL CONSTRAINT FK_content_content_models FOREIGN KEY REFERENCES /*_*/content_models(model_id),
+
+ -- URL-like address of the content blob
+ content_address nvarchar(255) NOT NULL
+);
+
+--
+-- Normalization table for role names
+--
+CREATE TABLE /*_*/slot_roles (
+ role_id smallint NOT NULL CONSTRAINT PK_slot_roles PRIMARY KEY IDENTITY,
+ role_name nvarchar(64) NOT NULL
+);
+
+-- Index for looking of the internal ID of for a name
+CREATE UNIQUE INDEX /*i*/role_name ON /*_*/slot_roles (role_name);
+
+--
+-- Normalization table for content model names
+--
+CREATE TABLE /*_*/content_models (
+ model_id smallint NOT NULL CONSTRAINT PK_content_models PRIMARY KEY IDENTITY,
+ model_name nvarchar(64) NOT NULL
+);
+
+-- Index for looking of the internal ID of for a name
+CREATE UNIQUE INDEX /*i*/model_name ON /*_*/content_models (model_name);
+
+
--
-- Track page-to-page hyperlinks within the wiki.
--
--- /dev/null
+CREATE SEQUENCE content_content_id_seq;
+CREATE TABLE &mw_prefix.content (
+ content_id NUMBER NOT NULL,
+ content_size NUMBER NOT NULL,
+ content_sha1 VARCHAR2(32) NOT NULL,
+ content_model NUMBER NOT NULL,
+ content_address VARCHAR2(255) NOT NULL
+);
+
+ALTER TABLE &mw_prefix.content ADD CONSTRAINT &mw_prefix.content_pk PRIMARY KEY (content_id);
+
+/*$mw$*/
+CREATE TRIGGER &mw_prefix.content_seq_trg BEFORE INSERT ON &mw_prefix.content
+ FOR EACH ROW WHEN (new.content_id IS NULL)
+BEGIN
+ &mw_prefix.lastval_pkg.setLastval(content_content_id_seq.nextval, :new.content_id);
+END;
+/*$mw$*/
\ No newline at end of file
--- /dev/null
+CREATE SEQUENCE content_models_model_id_seq;
+CREATE TABLE &mw_prefix.content_models (
+ model_id NUMBER NOT NULL,
+ model_name VARCHAR2(64) NOT NULL
+);
+
+
+ALTER TABLE &mw_prefix.content_models ADD CONSTRAINT &mw_prefix.content_models_pk PRIMARY KEY (model_id);
+
+CREATE UNIQUE INDEX &mw_prefix.model_name_u01 ON &mw_prefix.content_models (model_name);
+
+/*$mw$*/
+CREATE TRIGGER &mw_prefix.content_models_seq_trg BEFORE INSERT ON &mw_prefix.content_models
+ FOR EACH ROW WHEN (new.model_id IS NULL)
+BEGIN
+ &mw_prefix.lastval_pkg.setLastval(content_models_model_id_seq.nextval, :new.model_id);
+END;
+/*$mw$*/
\ No newline at end of file
--- /dev/null
+CREATE SEQUENCE slot_roles_role_id_seq;
+CREATE TABLE &mw_prefix.slot_roles (
+ role_id NUMBER NOT NULL,
+ role_name VARCHAR2(64) NOT NULL
+);
+
+ALTER TABLE &mw_prefix.slot_roles ADD CONSTRAINT &mw_prefix.slot_roles_pk PRIMARY KEY (role_id);
+
+CREATE UNIQUE INDEX &mw_prefix.role_name_u01 ON &mw_prefix.slot_roles (role_name);
+
+/*$mw$*/
+CREATE TRIGGER &mw_prefix.slot_roles_seq_trg BEFORE INSERT ON &mw_prefix.slot_roles
+ FOR EACH ROW WHEN (new.role_id IS NULL)
+BEGIN
+ &mw_prefix.lastval_pkg.setLastval(slot_roles_role_id_seq.nextval, :new.role_id);
+END;
+/*$mw$*/
\ No newline at end of file
--- /dev/null
+CREATE TABLE &mw_prefix.slots (
+ slot_revision_id NUMBER NOT NULL,
+ slot_role_id NUMBER NOT NULL,
+ slot_content_id NUMBER NOT NULL,
+ slot_inherited CHAR(1) DEFAULT '0' NOT NULL
+);
+
+ALTER TABLE &mw_prefix.slots ADD CONSTRAINT &mw_prefix.slots_pk PRIMARY KEY (slot_revision_id, slot_role_id);
+
+CREATE INDEX &mw_prefix.slot_role_inherited ON &mw_prefix.slots (slot_revision_id, slot_role_id, slot_inherited);
\ No newline at end of file
END;
/*$mw$*/
+
+CREATE TABLE &mw_prefix.slots (
+ slot_revision_id NUMBER NOT NULL,
+ slot_role_id NUMBER NOT NULL,
+ slot_content_id NUMBER NOT NULL,
+ slot_inherited CHAR(1) DEFAULT '0' NOT NULL
+);
+
+ALTER TABLE &mw_prefix.slots ADD CONSTRAINT &mw_prefix.slots_pk PRIMARY KEY (slot_revision_id, slot_role_id);
+
+CREATE INDEX &mw_prefix.slot_role_inherited ON &mw_prefix.slots (slot_revision_id, slot_role_id, slot_inherited);
+
+
+CREATE SEQUENCE content_content_id_seq;
+CREATE TABLE &mw_prefix.content (
+ content_id NUMBER NOT NULL,
+ content_size NUMBER NOT NULL,
+ content_sha1 VARCHAR2(32) NOT NULL,
+ content_model NUMBER NOT NULL,
+ content_address VARCHAR2(255) NOT NULL
+);
+
+ALTER TABLE &mw_prefix.content ADD CONSTRAINT &mw_prefix.content_pk PRIMARY KEY (content_id);
+
+/*$mw$*/
+CREATE TRIGGER &mw_prefix.content_seq_trg BEFORE INSERT ON &mw_prefix.content
+ FOR EACH ROW WHEN (new.content_id IS NULL)
+BEGIN
+ &mw_prefix.lastval_pkg.setLastval(content_content_id_seq.nextval, :new.content_id);
+END;
+/*$mw$*/
+
+
+CREATE SEQUENCE slot_roles_role_id_seq;
+CREATE TABLE &mw_prefix.slot_roles (
+ role_id NUMBER NOT NULL,
+ role_name VARCHAR2(64) NOT NULL
+);
+
+ALTER TABLE &mw_prefix.slot_roles ADD CONSTRAINT &mw_prefix.slot_roles_pk PRIMARY KEY (role_id);
+
+CREATE UNIQUE INDEX &mw_prefix.role_name_u01 ON &mw_prefix.slot_roles (role_name);
+
+/*$mw$*/
+CREATE TRIGGER &mw_prefix.slot_roles_seq_trg BEFORE INSERT ON &mw_prefix.slot_roles
+ FOR EACH ROW WHEN (new.role_id IS NULL)
+BEGIN
+ &mw_prefix.lastval_pkg.setLastval(slot_roles_role_id_seq.nextval, :new.role_id);
+END;
+/*$mw$*/
+
+
+CREATE SEQUENCE content_models_model_id_seq;
+CREATE TABLE &mw_prefix.content_models (
+ model_id NUMBER NOT NULL,
+ model_name VARCHAR2(64) NOT NULL
+);
+
+
+ALTER TABLE &mw_prefix.content_models ADD CONSTRAINT &mw_prefix.content_models_pk PRIMARY KEY (model_id);
+
+CREATE UNIQUE INDEX &mw_prefix.model_name_u01 ON &mw_prefix.content_models (model_name);
+
+/*$mw$*/
+CREATE TRIGGER &mw_prefix.content_models_seq_trg BEFORE INSERT ON &mw_prefix.content_models
+ FOR EACH ROW WHEN (new.model_id IS NULL)
+BEGIN
+ &mw_prefix.lastval_pkg.setLastval(content_models_model_id_seq.nextval, :new.model_id);
+END;
+/*$mw$*/
+
+
CREATE TABLE &mw_prefix.pagelinks (
pl_from NUMBER NOT NULL,
pl_namespace NUMBER DEFAULT 0 NOT NULL,
--- /dev/null
+CREATE SEQUENCE content_content_id_seq;
+CREATE TABLE content (
+ content_id INTEGER NOT NULL PRIMARY KEY DEFAULT nextval('content_content_id_seq'),
+ content_size INTEGER NOT NULL,
+ content_sha1 TEXT NOT NULL,
+ content_model SMALLINT NOT NULL,
+ content_address TEXT NOT NULL
+);
--- /dev/null
+CREATE SEQUENCE content_models_model_id_seq;
+CREATE TABLE content_models (
+ model_id SMALLINT NOT NULL PRIMARY KEY DEFAULT nextval('content_models_model_id_seq'),
+ model_name TEXT NOT NULL
+);
+
+CREATE UNIQUE INDEX model_name ON content_models (model_name);
\ No newline at end of file
--- /dev/null
+CREATE SEQUENCE slot_roles_role_id_seq;
+CREATE TABLE slot_roles (
+ role_id SMALLINT NOT NULL PRIMARY KEY DEFAULT nextval('slot_roles_role_id_seq'),
+ role_name TEXT NOT NULL
+);
+
+CREATE UNIQUE INDEX role_name ON slot_roles (role_name);
\ No newline at end of file
--- /dev/null
+CREATE TABLE slots (
+ slot_revision_id INTEGER NOT NULL,
+ slot_role_id SMALLINT NOT NULL,
+ slot_content_id INTEGER NOT NULL,
+ slot_inherited SMALLINT NOT NULL DEFAULT 0,
+ PRIMARY KEY (slot_revision_id, slot_role_id)
+);
+
+CREATE INDEX slot_role_inherited ON slots (slot_revision_id, slot_role_id, slot_inherited);
\ No newline at end of file
CREATE INDEX archive_user_text ON archive (ar_user_text);
+CREATE TABLE slots (
+ slot_revision_id INTEGER NOT NULL,
+ slot_role_id SMALLINT NOT NULL,
+ slot_content_id INTEGER NOT NULL,
+ slot_inherited SMALLINT NOT NULL DEFAULT 0,
+ PRIMARY KEY (slot_revision_id, slot_role_id)
+);
+
+CREATE INDEX slot_role_inherited ON slots (slot_revision_id, slot_role_id, slot_inherited);
+
+
+CREATE SEQUENCE content_content_id_seq;
+CREATE TABLE content (
+ content_id INTEGER NOT NULL PRIMARY KEY DEFAULT nextval('content_content_id_seq'),
+ content_size INTEGER NOT NULL,
+ content_sha1 TEXT NOT NULL,
+ content_model SMALLINT NOT NULL,
+ content_address TEXT NOT NULL
+);
+
+
+CREATE SEQUENCE slot_roles_role_id_seq;
+CREATE TABLE slot_roles (
+ role_id SMALLINT NOT NULL PRIMARY KEY DEFAULT nextval('slot_roles_role_id_seq'),
+ role_name TEXT NOT NULL
+);
+
+CREATE UNIQUE INDEX role_name ON slot_roles (role_name);
+
+
+CREATE SEQUENCE content_models_model_id_seq;
+CREATE TABLE content_models (
+ model_id SMALLINT NOT NULL PRIMARY KEY DEFAULT nextval('content_models_model_id_seq'),
+ model_name TEXT NOT NULL
+);
+
+CREATE UNIQUE INDEX model_name ON content_models (model_name);
+
+
CREATE TABLE redirect (
rd_from INTEGER NOT NULL REFERENCES page(page_id) ON DELETE CASCADE DEFERRABLE INITIALLY DEFERRED,
rd_namespace SMALLINT NOT NULL,
-- rows, such as change_tag.
CREATE INDEX /*i*/ar_revid ON /*_*/archive (ar_rev_id);
+--
+-- Slots represent an n:m relation between revisions and content objects.
+-- A content object can have a specific "role" in one or more revisions.
+-- Each revision can have multiple content objects, each having a different role.
+--
+CREATE TABLE /*_*/slots (
+
+ -- reference to rev_id
+ slot_revision_id bigint unsigned NOT NULL,
+
+ -- reference to role_id
+ slot_role_id smallint unsigned NOT NULL,
+
+ -- reference to content_id
+ slot_content_id bigint unsigned NOT NULL,
+
+ -- whether the content is inherited (1) or new in this revision (0)
+ slot_inherited tinyint unsigned NOT NULL DEFAULT 0,
+
+ PRIMARY KEY ( slot_revision_id, slot_role_id )
+) /*$wgDBTableOptions*/;
+
+-- Index for finding revisions that modified a specific slot
+CREATE INDEX /*i*/slot_role_inherited ON /*_*/slots (slot_revision_id, slot_role_id, slot_inherited);
+
+--
+-- The content table represents content objects. It's primary purpose is to provide the necessary
+-- meta-data for loading and interpreting a serialized data blob to create a content object.
+--
+CREATE TABLE /*_*/content (
+
+ -- ID of the content object
+ content_id bigint unsigned PRIMARY KEY AUTO_INCREMENT,
+
+ -- Nominal size of the content object (not necessarily of the serialized blob)
+ content_size int unsigned NOT NULL,
+
+ -- Nominal hash of the content object (not necessarily of the serialized blob)
+ content_sha1 varbinary(32) NOT NULL,
+
+ -- reference to model_id
+ content_model smallint unsigned NOT NULL,
+
+ -- URL-like address of the content blob
+ content_address varbinary(255) NOT NULL
+) /*$wgDBTableOptions*/;
+
+--
+-- Normalization table for role names
+--
+CREATE TABLE /*_*/slot_roles (
+ role_id smallint PRIMARY KEY AUTO_INCREMENT,
+ role_name varbinary(64) NOT NULL
+) /*$wgDBTableOptions*/;
+
+-- Index for looking of the internal ID of for a name
+CREATE UNIQUE INDEX /*i*/role_name ON /*_*/slot_roles (role_name);
+
+--
+-- Normalization table for content model names
+--
+CREATE TABLE /*_*/content_models (
+ model_id smallint PRIMARY KEY AUTO_INCREMENT,
+ model_name varbinary(64) NOT NULL
+) /*$wgDBTableOptions*/;
+
+-- Index for looking of the internal ID of for a name
+CREATE UNIQUE INDEX /*i*/model_name ON /*_*/content_models (model_name);
--
-- Track page-to-page hyperlinks within the wiki.